#pragma once
#include <string>
#include "../common/define.h"
#include <Windows.h>
#include <vector>
#include <fstream>

using namespace std;


class DLLEXP CLogger
{
public:

	enum EnumLevel
	{
		_LOG_,
		_WARNING_,
		_DEBUG_,
		_ERROR_,
	};
	struct NoteItem
	{
		EnumLevel type;
		bool effect;
		bool tofile;
		bool toconsole;
		NoteItem()
		{
			effect = false;
			tofile = false;
			toconsole = true;
		}
	};

	~CLogger(void);
	static void log(EnumLevel Level,string fileName, int lineNumber,string functionName, string formatString, ...);
	static void log(EnumLevel Level,string formatString, ...);
	static void logHex(EnumLevel Level,string str);

	
	static CLogger* Ins();
	void SetConsoleColor(WORD color);
	bool QueryToFile(EnumLevel Level);
	void SetToFile(EnumLevel Level,bool isfile);
	bool QueryToConsole(EnumLevel Level);
	void SetToConsole(EnumLevel Level,bool isconsole);
	void LoadConfig();

	void SetLogFileDir(string str);
	string GetLogFileDir();
	void SetLogFileName(string str);
	string GetLogFileName();
	void SetConfigFileDir(string str);
	string GetConfigFileDir();
	void SetConfigFileName(string str);
	string GetConfigFileName();
protected:
	void WriteToFile( string formatString);
	void OpenFile();
	CLogger(void);
private:
	vector<WORD> m_colors;
	static CLogger* m_pLogger;
	ofstream m_filestream;
	string m_strLogFileDir;
	string  m_strLogFileName;
	string m_strConfigFileDir;
	string m_strConfigFileName;
	vector<NoteItem> m_NoteItemAttributes;
};